{% extends "base/base_width_left.html" %}
{% load pagination_tags %}

{% block flag %}server{% endblock %}
{% block path %}
    <a href="" title="" class="tip-bottom">项目/节点管理</a>
{% endblock %}

{#{% block searchname %}searchaction{% endblock %}#}
{#{% block searchtip %}订单编号{% endblock %}#}

{% block container %}
    {{ block.super }}
        {% autopaginate server_list %}
        <ul class="nav nav-tabs">
            <li role="presentation"><a href="{% url 'server:manage_list' %}">项目管理列表</a></li>
            <li role="presentation" class="active"><a href="{% url 'server:list' %}">节点列表</a></li>    {#        <li role="presentation"><a href="{% url 'product:theme_list' %}">主题</a></li>#}
        </ul>
    <div hidediv="hide" class="center-block">
        <div class="dropdown" style="display:inline">
{#                        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"#}
            {#                                aria-expanded="true">#}
            {#                            按分类查看#}
            {#                            <span class="caret"></span>#}
            {#                        </button>#}
            <a class="btn btn-default dropdown-toggle" type="button" href="{% url 'server:editor' %}">
                           创建
            </a>
            {#            <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">#}
            {#                <li role="presentation">#}
            {#                    <a role="menuitem" tabindex="-1" href="{% url 'order:order_list' %}">全部</a>#}
            {#                </li>#}
            {#                {% for status in status_tuple %}#}
            {#                    <li role="presentation">#}
            {#                        <a role="menuitem" tabindex="-1"#}
            {#                           href="{% url 'order:order_list' %}?status={{ status.0 }}">{{ status.1 }}</a>#}
            {#                    </li>#}
            {#                {% endfor %}#}
            {#            </ul>#}
        </div>
        <form method="get">
            <input class="input-sm" name="searchaction" placeholder="输入服务器/节点ip搜索"/>
            <button class="btn btn-default">搜索</button>
        {#        <a href="{% url 'product:product_form' %}" class="btn btn-primary">添 加</a>#}
        </form>
    </div>
    <div hidediv="hide" class="table-responsive">
        <table class="table table-hover table-bordered ">
            <thead>
            <tr>
                <th>节点ip</th>
                <th>节点端口</th>
                <th>节点帐号</th>
                <th>节点密码</th>
{#                <th>服务器状态</th>#}
{#                <th>操作</th>#}
{#                <th>剧本路径</th>#}
{#                <th>更新时间</th>#}
                <th>操作</th>
            </tr>
            </thead>
            {% for server in server_list %}
                <tr>
                    <td>{{ server.ip }}</td>
                    <td>
                        {{ server.port }}
                    </td>
                    <td>{{ server.ssh_user }}</td>
                    <td>
{#                        {{ server.ssh_password }}#}
                        ******
                    </td>
{#                    <td>{{ server.get_status_display }}</td>#}
                    <td>
                        <a class="btn btn-default btn-sm"
                                href="{% url 'server:editor' sid=server.id%}">编辑
                        </a>
                        <a class="btn btn-default btn-sm"
                                href="{% url 'server:detail' pk=server.id%}">详情
                        </a>
                        <button class="btn deletebtn btn-default btn-sm"
                                deleteurl="{% url 'server:delete' sid=server.id%} ">删除
                        </button>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="8"><p>没有查询到相关信息.</p></td>
                </tr>
            {% endfor %}
        </table>
     {% paginate %}
{#        <div class="pagination">#}
{#            <span class="step-links">#}
{#                {% if page_obj.has_previous %}#}
{#                    <a href="?page={{ page_obj.prevous_page_number }}">上一页</a>#}
{#                {% endif %}#}
{#                <span class="current">#}
{#                    page {{ page_obj.number }} of {{ paginator.num_pages }}.#}
{#                </span>#}
{#                {% if page_obj.has_next %}#}
{##}
{#                    <a href="?page={{ page_obj.next_page_number }}">下一页</a>#}
{#                {% endif %}#}
{#            </span>#}
{#        </div>#}

    </div>
{% endblock %}
{% block footjs %}
{#    <script>#}
{#        $('.change_status').click("on", function () {#}
{#            var url = $(this).attr('change_url');#}
{#            $(this).attr('disabled', 'disabled');#}
{#            var yes = function () {#}
{#                //退款需要时间，显示加载的提示#}
{#                layer.load(2, {time: 10 * 1000});#}
{#                $.get(url, {}, function (data) {#}
{#                    if (data.url) {#}
{#                        window.open(data.url);#}
{#                    } else if (data.code == 1) {#}
{#                        showMsg(options = {msg: "修改成功"});#}
{#                        location.reload();#}
{#                    } else {#}
{#                        location.reload();#}
{#                    }#}
{##}
{#                })#}
{#            };#}
{#            showYesorNo("是否修改订单状态", yes);#}
{##}
{#        });#}
{#        $('.shipments').on('click', function () {#}
{#            var url = $(this).attr('change_url');#}
{#            var options = {#}
{#                title: "增加物流",#}
{#                area: ['300', '400'],#}
{#                content: [url, 'no'],#}
{#                yes: function (index) {#}
{#                    var logistics_form = layer.getChildFrame("form", index);#}
{#                    if (logistics_form.find('#id_logistics_id').val() == '' || logistics_form.find('#id_logistics_company').val() == '') {#}
{#                        showMsg(options = {msg: "物流单号或物流公司未填", icon: 5});#}
{#                    } else {#}
{#                        $.post(url, logistics_form.serialize(), function (data) {#}
{#                            if (data == 1) {#}
{#                                location.reload();#}
{#                            } else if (data == 0) {#}
{#                                showMsg(options = {msg: "修改失败", icon: 5});#}
{#                            } else {#}
{#                                location.href = data;#}
{#                            }#}
{#                            ;#}
{#                        });#}
{##}
{#                    }#}
{#                },#}
{#            }#}
{#            showIframe(options)#}
{#        });#}
{#    </script>#}
{% endblock %}
